< previous page page_132 next page >

Page 132
Type.gifListing 5.12. Adding the KeyFilter declarations to the VText control.
' ------------------------------------------------
' KeyFilter values
'
' Event list
Public Event NumericError(KeyAscii)
Public Event DigitsError(KeyAscii)
'Default Property Values:
Const m_def_UpperCase = 0
Const m_def_Digits = 0
Const m_def_Numeric = 0
'Property Variables:
Dim m_UpperCase As Boolean
Dim m_Digits As Boolean
Dim m_Numeric As Boolean
Dim m_Text As String
The code in Listing 5.12 establishes two events that fire messages back to your Visual Basic program if an invalid key is pressed. This code also defines local storage for three Boolean properties and one string property. The three Boolean properties also have a default value defined. You add the new Public properties in just a moment.
First, add some code to the InitProperties event to set the default values for these new properties. The code in Listing 5.13 shows the modified UserControl_InitProperties event.
Type.gifListing 5.13. Adding KeyFilter defaults to the InitProperties event.
Private Sub UserControl_InitProperties()
    '
    ' initialize control values
    '
    With UserControl
        .Width = 1200
        .Height = 300
    End With
    '
    Text1.Text = UserControl.Name
    '
    ' KeyFilter properties
    m_UpperCase = m_def_UpperCase
    m_Digits = m_def_Digits
    m_Numeric = m_def_Numeric
    '
End Sub
Now it's time to create the new properties to match the local storage variables. To create properties for your control, select Tools | Add Procedure from the main menu. This brings

 
< previous page page_132 next page >

If you like this book, buy it!